/*
* @Author: Choisaaaa
* @Date: 2018/5/22  10:50
*/

var _mm = require("util/mm.js");


var _seller = {
    //1.店家注册
    register : function(sellerInfo,resolve,reject) {
        _mm.request({
            url : _mm.getServerUrl("/seller/register.do"),
            data : sellerInfo,
            method :"POST",
            success : resolve,
            error : reject
        });
    },

    //表单字段验证
    formValidate : function(formData){
        console.log(formData)
        var result = {
            status : false,
            msg : ""
        };
        //验证用户名不能为空
        if(!_mm.validate(formData.sellerRealName,"require")){
            result.msg = "请输入你的真实姓名";
            return result;
        }
        //验证所在学校
        if(formData.sellerSchool == "999"){
            if(!_mm.validate(formData.selfSchool,"require")){
                result.msg = "请在输入框输入你所在的学校！";
                return result;
            }else{
                formData.sellerSchool = formData.selfSchool;
            }
        }else if(!_mm.validate(formData.sellerSchool,"require")){
            result.msg = "请下拉框选择学校！";
            return result;
        }

        //验证学号不能为空
        if(!_mm.validate(formData.sellerSchoolNumber,"require")){
            result.msg = "学号不能为空！"
            return result;
        }
        //通过验证返回，正确提示
        result.status = true;
        result.msg = "验证通过";
        return result;
    }
}


module.exports = _seller;